-- card: 59314 from stack: in -- bmap block id: 0 -- flags: 0000 -- background id: 4755 -- name: -- part contents for background part 4 ----- text ----- TC OBJECT EXTENSIONS Think C 4.0 extends ANSI C with a few C++ features, as detailed in Chapter 4. Most importantly, the definition of a 'struct' user-defined type may contain function prototypes, in which case the structure is called a "class". These "member functions" (or "methods") may refer directly to variables which are members of the same class; that is, these "instance" variables are said to have "class scope". (Unlike C++, the name of a class may itself be assigned to a void pointer variable or passed to a function.*) When a pointer to a variable of the class type is declared, the 'struct' keyword is not required, and the variable is called an "object". Space for this variable is allocated dynamically using the new() function. The member functions associated with this object may be accessed via the pointer using the '->' operator, which is termed "sending a message to the object". The variable is deallocated using the delete() function. New classes can be defined which are "derived" from existing classes. The derived classes "inherit" all the instance variables and methods of the base class, and may add -- part contents for background part 7 ----- text ----- 216 -- part contents for background part 29 ----- text ----- 6547 -- part contents for background part 27 ----- text ----- Alternative new() function -- part contents for background part 20 ----- text ----- Alternative new() function - p209